package com.zsrt.day20170506.singleton;
/**
*@author jzh
*@创建时间 2017年5月6日下午12:13:24
*类说明：单例模式的双重检查锁
*/
/*public class Singleton2 {
	
	private static Singleton2 instance;
	
	private Singleton2(){}
	
	public static Singleton2 getInstance(){
		if(null==instance){
			synchronized(Singleton2.class){
				if(null==instance){
					instance=new Singleton2();
				}
			}
		}
		return instance;
	}

}*/

public class Singleton2 {
	private static Singleton2 instance;
	
	private Singleton2(){};
	
	public static Singleton2 getInstance(){
		if(null==instance){
			synchronized(Singleton2.class){
				if(null==instance){
					instance=new Singleton2();
				}
			}
		}
		return instance;
	}
}

